﻿@model IEnumerable<Gas.Models.Empresa>
@{ /*Layout = null;*/ }
<div class="table-responsive">
    <div id="EmpresaTable" style="width: 580px; margin: auto;"></div>
</div>

<script type="text/javascript">
    $(document).ready(function () {
        //Prepare jtable plugin
        $('#EmpresaTable').jtable({
            title: 'Empresas',
            sorting: true,
            actions: {
                listAction: '@Url.Action("Listagem")',
                //deleteAction: '/Empresa/Excluir',
                //updateAction: '@Url.Action("Alteracao")',
                //createAction: '/empresa/cadastro'
            },
            fields: {                
                RazaoSocial: {
                    title: 'Razão Social',
                    width: '15%'
                },
                Cep: {
                    title: 'Cep',
                    list: true
                },
                Uf: {
                    title: 'UF',                    
                    list: true
                },
                Cidade: {
                    title: 'Cidade',
                    list: true
                },
                Bairro: {
                    title: 'Bairro',
                    list: true
                },                
                Alteracao: {
                    title: '',
                    display: function(data) {
                        //return '<button type="button" onclick="alert(' + data.record.Cep + ')">alterar</button>';
                        return '<a href="/empresa/alteracao?id=' + data.record.Id + '">alt</a>';
                    }
                },
                Exclusao: {
                    title: '',
                    display: function(data) {
                        //return '<button type="button" onclick="alert(' + data.record.Cep + ')">alterar</button>';
                        return '<a href="/empresa/exclusao?id=' + data.record.Id + '">exc</a>';
                    }
                }
            }
        });

        //Load person list from server
        $('#EmpresaTable').jtable('load');
    });

</script>